/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package oplm;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author hh
 */
@Entity
@Table(name = "CDKBN", catalog = "", schema = "APP")
@NamedQueries({
    @NamedQuery(name = "Cdkbn.findAll", query = "SELECT c FROM Cdkbn c"),
    @NamedQuery(name = "Cdkbn.findByMainCd", query = "SELECT c FROM Cdkbn c WHERE c.cdkbnPK.mainCd = :mainCd"),
    @NamedQuery(name = "Cdkbn.findBySubCd", query = "SELECT c FROM Cdkbn c WHERE c.cdkbnPK.subCd = :subCd"),
    @NamedQuery(name = "Cdkbn.findByNm", query = "SELECT c FROM Cdkbn c WHERE c.nm = :nm")})
public class Cdkbn implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CdkbnPK cdkbnPK;
    @Column(name = "NM")
    private String nm;

    public Cdkbn() {
    }

    public Cdkbn(CdkbnPK cdkbnPK) {
        this.cdkbnPK = cdkbnPK;
    }

    public Cdkbn(int mainCd, int subCd) {
        this.cdkbnPK = new CdkbnPK(mainCd, subCd);
    }

    public CdkbnPK getCdkbnPK() {
        return cdkbnPK;
    }

    public void setCdkbnPK(CdkbnPK cdkbnPK) {
        this.cdkbnPK = cdkbnPK;
    }

    public String getNm() {
        return nm;
    }

    public void setNm(String nm) {
        String oldNm = this.nm;
        this.nm = nm;
        changeSupport.firePropertyChange("nm", oldNm, nm);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdkbnPK != null ? cdkbnPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cdkbn)) {
            return false;
        }
        Cdkbn other = (Cdkbn) object;
        if ((this.cdkbnPK == null && other.cdkbnPK != null) || (this.cdkbnPK != null && !this.cdkbnPK.equals(other.cdkbnPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNm();
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
